<?php

/**
 * sfCronManagerJob filter form base class.
 *
 * @package    symfony
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BasesfCronManagerJobFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'title'                   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'command'                 => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'schedule'                => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'active'                  => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'load_limit'              => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'current_suppressed_runs' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'max_suppressed_runs'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'run_if_missed'           => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'last_ran'                => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'next_run'                => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'title'                   => new sfValidatorPass(array('required' => false)),
      'command'                 => new sfValidatorPass(array('required' => false)),
      'schedule'                => new sfValidatorPass(array('required' => false)),
      'active'                  => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'load_limit'              => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'current_suppressed_runs' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'max_suppressed_runs'     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'run_if_missed'           => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'last_ran'                => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'next_run'                => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('sf_cron_manager_job_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'sfCronManagerJob';
  }

  public function getFields()
  {
    return array(
      'id'                      => 'Number',
      'title'                   => 'Text',
      'command'                 => 'Text',
      'schedule'                => 'Text',
      'active'                  => 'Boolean',
      'load_limit'              => 'Number',
      'current_suppressed_runs' => 'Number',
      'max_suppressed_runs'     => 'Number',
      'run_if_missed'           => 'Boolean',
      'last_ran'                => 'Date',
      'next_run'                => 'Date',
    );
  }
}
